<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>多级树形分类</title>

    <!--图标样式-->
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />

    <!--主要样式-->
    <link rel="stylesheet" type="text/css" href="css/style.css" />

    <script type="text/javascript" src="lib/jquery.min.js"></script>

</head>
<body>

<div id="tree" class="tree well"></div>
<script type="text/javascript" src="./js/tree.js"></script>

<script type="text/javascript">
    $.ajaxSettings.async = false;
    $.get('/tree', function (data) {
        f(data)
        $("#tree").html("<ul>"+text+"</ul>")
    })
    $(function(){
        $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
        $('.tree li.parent_li > span').on('click', function (e) {
            var children = $(this).parent('li.parent_li').find(' > ul > li');
            if (children.is(":visible")) {
                children.hide('fast');
                $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
            } else {
                children.show('fast');
                $(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
            }
            e.stopPropagation();
        });
    });
</script>
</body>
</html>